package com.practise.rocketmqdemo.listen;

import com.practise.rocketmqdemo.constant.MQConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 ** topic需要和生产者的topic一致，consumerGroup属性是必须指定的，内容可以随意
 ** selectorExpression的意思指的就是tag，默认为“*”，不设置的话会监听所有消息
 * 消息有序消费还是并发消费则由consumeMode属性定制。
 * 消费者是集群部署还是广播部署由messageModel属性定制。
 */
@Slf4j
@Component
@RocketMQMessageListener(consumerGroup = "cgroup1", topic = MQConstant.TOPIC_ONE )
public class TopicOneReceiver implements RocketMQListener {

    @Override
    public void onMessage(Object msg) {
        log.info("监听:cgroup1 TOPIC_ONE msg:{}" ,msg);
    }
}